package com.ding.custommanagersys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ding.custommanagersys.bo.AreaBo;
import com.ding.custommanagersys.entity.Member;
import com.ding.custommanagersys.mapper.MemberMapper;
import com.ding.custommanagersys.service.IMemberService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ding
 * @since 2023-04-18
 */
@Service
public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> implements IMemberService {

    @Autowired
    private MemberMapper memberMapper;

    @Override
    public Page<Member> listAllMember(AreaBo bo) {
        Page<Member> page = new Page<>(bo.getPageNo(),bo.getPageSize());
        List<Member> members = memberMapper.listAllMember(page, bo.getId());
        page.setRecords(members);
        return page;
    }

    @Override
    public Integer addMember(Member member) {
        return memberMapper.insert(member);
    }

    @Override
    public Integer deleteMember(List<Integer> ids) {
        return memberMapper.deleteMember(ids);
    }

    @Override
    public Integer updateMember(Member member) {
        return memberMapper.updateMember(member);
    }

    @Override
    public Member getOneMember(int id) {
        QueryWrapper<Member> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("t_id",id);
        return getOne(queryWrapper);
    }

    @Override
    public List<Member> listMember() {
        return list();
    }
}
